package com.jz.digital.utils.eventbus;

import com.jz.digital.base.BaseMessage;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class EventBusWrapper {

    public IHandlerEventBus iHandlerEventBus;

    public void register(IHandlerEventBus iHandlerEventBus) {
        this.iHandlerEventBus = iHandlerEventBus;
        EventBusHelper.register(this);
    }

    public void unregister() {
        iHandlerEventBus = null;
        EventBusHelper.unregister(this);
    }

    /**
     * 接收EventBus发送的消息
     *
     * @param msgEvent 消息
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void handleMessageEvent(BaseMessage msgEvent) {
        if (iHandlerEventBus != null) {
            iHandlerEventBus.handleMessage(msgEvent);
        }
//        handleEvenBusMsg(msgEvent);//子类接收EventBus的消息，需要实现handleEvenBusMsg方法
    }
}
